﻿using GrainInterfaces;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.Threading;

try
{
    IHost host = Host.CreateDefaultBuilder(args)
    .UseOrleansClient(client =>
    {
        client.UseLocalhostClustering();
    })
    .ConfigureLogging(logging => logging.AddConsole())
    .UseConsoleLifetime()
    .Build();

    await host.StartAsync();

    IClusterClient client = host.Services.GetRequiredService<IClusterClient>();

    IHello friend = client.GetGrain<IHello>(0);

    //string response = await friend.SayHello("Hi friend!");

    //Console.WriteLine($"""{response}Press any key to exit...""");

    for (int i = 0; i < 99999999; i++)
    {
        Thread.Sleep(500);
        string response = await friend.SayHello($"Hi friend!{i}");

        Console.WriteLine($"""{response}Press any key to exit...{i}""");
    }


    Console.ReadKey();

    await host.StopAsync();
}
catch (Exception)
{

}
